/* $Id: qx-base.js 10 2012-04-08 15:34:15Z zhaofang123 $ */
var qx = qx || {};

// Ajax请求
qx.request = function(aUrl, data, successFunc, failFunc, method, async){
	var req = new Request({
		url: aUrl,
		method: method || 'GET',
		async: !!!async ? true : !!async,
		onSuccess: successFunc || function(respText, respXml){
			alert(responseText);
		},
		onFailure: failFunc || function(xhr){
			alert('Request fail: ' + xhr);
		},
		onException: function(headerName, value){
			alert('Bad header set: ' + headerName + ' = ' + value);
		}
	});
	req.send(data);
};

// 居中
qx.center = function(el, x, y){
	var wxy = $(document.body).getScrollSize();
	var xy = el.getSize();
	x = x || true; y = y || true;
	if (x == true) el.setStyle('left', (wxy.x - xy.x) / 2);
	if (y == true) el.setStyle('top', (wxy.y - xy.y) / 2);
}

// 获取/设置 值
qx.value = function(el, val){
}

// 焦点
qx.focus = function(el){
	try{
		el.focus();
	} catch (ex){}
}
